﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Engine
{
    class Particle
    {
        Vector2 mVelocity;
        Vector2 mPosition;
        Color mColor;
        float mDecay; //Que tan rapido muere la particula
        float mAlpha;
        float mAngle; //Angulo final de rotacion.
        float mRotation;//Cuanto tenemos que rotar el angulo.
        bool mIsVisible;

        public Particle() { }
        public Particle(Vector2 pos,Vector2 vel,float rotation)
        {
            mPosition = pos;
            mVelocity = vel;
            mAlpha = 255;
            mDecay = 0;
            mIsVisible = false;
            mAngle = 0;
            mRotation = rotation;
        }

        public void Update(GameTime gameTime)
        {
            mPosition += mVelocity;

            if ((mAlpha - mDecay) > 0)
                mAlpha -= mDecay;
            else
            {
                mIsVisible = false;
            }
            mAngle += mRotation;

            mColor.R = (byte)mAlpha;
            mColor.G = (byte)mAlpha;
            mColor.B = (byte)mAlpha;
            mColor.A = (byte)mAlpha;
        }

        #region Sets

        public void SetRotation(float rotation){mRotation = rotation;}
        public void SetVelocity(Vector2 vel){mVelocity = vel;}
        public void SetIsVisible(bool v){mIsVisible = v;}
        public void SetPosition(Vector2 pos){mPosition = pos;}
        public void SetDecay(float decay) { mDecay = decay;}
        public void SetAlpha(int alpha) { mAlpha = alpha;}
        public void SetColor(Color color) { mColor = color; }

        #endregion

        #region Gets

        public Vector2 GetPosition(){return mPosition;}
        public Color GetColor(){return mColor;}
        public float GetAngle(){return mAngle;}
        public bool IsVisible() { return mIsVisible; }

        #endregion
    }
}
